#include <iostream>

class person{
public:
    int high;
    int *weight;
    person(){}
    person(int high, int weight){
        this->high = high;
        this->weight = new int(weight);
        std::cout<< "person 构造函数调用"<<std::endl;
    }
    person(const person &p){
        this->high = p.high;
        //深拷贝操作
        this->weight = new int(*p.weight);
        std::cout<< "person 拷贝构造函数调用"<<std::endl;
    }
    ~person(){
        if(weight != NULL){
            delete weight;
            weight = NULL;
        }
        std::cout<< "person 析构函数调用"<<std::endl;
    }
};
void function(){
    int w = 20;
    person p1(10, 20);
    person p2 = p1;
    std::cout<< p1.high <<std::endl;
    std::cout<< *p1.weight <<std::endl;
    std::cout<< p2.high <<std::endl;
    std::cout<< *p2.weight <<std::endl;
}

int main()
{   
    function();
    return 0;
}